package academic.ui.client.widgets;

import ui.client.GenericContainerTag;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class Footer extends Composite {

	GenericContainerTag div = new GenericContainerTag("div");
	Widget content=new Widget();
	public Footer() {
		div.setStyleName("footer");
		
		initWidget(div);
	}
	
	public void setContent(final Widget w) {
		this.content=w;
		div.clear();
		div.add(content);
		Window.addResizeHandler(new ResizeHandler() {

			@Override
			public void onResize(ResizeEvent event) {
				DOM.setStyleAttribute(content.getElement(), "left", String.valueOf((Window.getClientWidth()- content.getOffsetWidth())/2 )+"px");
				div.setHeight(String.valueOf(Math.max(80,Window.getClientHeight()-div.getAbsoluteTop()-content.getOffsetHeight()))+"px");
			}
			
		});
		
	}

	public void update() {
		//DOM.setStyleAttribute(content.getElement(), "left", String.valueOf((Window.getClientWidth()- content.getOffsetWidth())/2 )+"px");
		//div.setHeight(String.valueOf(Window.getClientHeight()-div.getAbsoluteTop()-content.getOffsetHeight())+"px");
	}
}
